<?php
 include 'DBconn.php';
class ProductMaster
{
public function getAllProduct()
{
$result=mysql_query("SELECT * from product_header where activestatus=1") or die(mysql_error());
$ret=array();
while($row=mysql_fetch_object($result))
    {
    $temp=new VOProductMaster();
     $temp->serialnumber=(int)$row->serialnumber;
     $temp->pro_code=$row->pro_code;
     $temp->pro_name=$row->pro_name;
     $temp->part_number=$row->part_number;
     $temp->stamp_number=$row->stamp_number;
     $temp->pro_oem=$row->pro_oem;
     $temp->qty_minimum=(double)$row->qty_minimum;
	 $temp->listprice=(double)$row->listprice;
	 $temp->discount=(double)$row->discount;
	 $temp->netprice=(double)$row->netprice;
     $temp->price=(double)$row->price;
     $temp->price1=(double)$row->price1;
     $temp->price2=(double)$row->price2;
     $temp->price3=(double)$row->price3;
     $temp->price4=(double)$row->price4;
	 $temp->price5=(double)$row->price5;
     $temp->price6=(double)$row->price6;
     $temp->currency_serialnumber=(int)$row->currency_serialnumber;
     $temp->pro_group=$row->pro_group;
     $temp->pro_category=$row->pro_category;
     $temp->pro_manufacturer=$row->pro_manufacturer;
     $temp->pro_manufacture_date=$row->pro_manufacture_date;
     $temp->pro_image=$row->pro_image;
     $temp->pro_sku=$row->pro_sku;
     $temp->cre_userid=(int)$row->cre_userid;
     $temp->cre_datetime=$row->cre_datetime;
     $temp->activestatus=(boolean)$row->activestatus;
     $temp->pro_description=$row->pro_description;
     $ret[]=$temp;
    }
mysql_free_result($result);
return $ret;
}

public  function addNewProduct($VObject)
{
      $query="insert into product_header(pro_code,pro_name,part_number,stamp_number,pro_oem,qty_minimum,listprice,discount,netprice,price,price1,price2,price3,price4,price5,price6,currency_serialnumber,pro_group,pro_category,pro_manufacturer,pro_manufacture_date,pro_image,pro_sku,cre_userid,cre_datetime,pro_description,activestatus)values('$VObject->pro_code','$VObject->pro_name','$VObject->part_number','$VObject->stamp_number','$VObject->pro_oem','$VObject->qty_minimum','$VObject->listprice','$VObject->discount','$VObject->netprice','$VObject->price','$VObject->price1','$VObject->price2','$VObject->price3','$VObject->price4','$VObject->price5','$VObject->price6','$VObject->currency_serialnumber','$VObject->pro_group','$VObject->pro_category','$VObject->pro_manufacturer','$VObject->pro_manufacture_date','$VObject->pro_image','$VObject->pro_sku','$VObject->cre_userid','$VObject->cre_datetime','$VObject->pro_description',1)";
      $s=  mysql_query("$query") or die(mysql_error());
        if ($s=1)
      {
        mysql_query("COMMIT");
      }
      else
      {
        mysql_query("ROLLBACK");
      }
      return 'true';
}

 public function deleteProduct($VObject)
{
  $s= mysql_query("update product_header set activestatus=0 where serialnumber=".$VObject->serialnumber) or die(mysql_error());
  if ($s=1)
      {
        mysql_query("COMMIT");
      }
      else
      {
        mysql_query("ROLLBACK");
      }
       return 'true';
  }

    public function editProduct($VObject)
  {
  $query="update product_header set pro_code='$VObject->pro_code',pro_name='$VObject->pro_name',part_number='$VObject->part_number',stamp_number='$VObject->stamp_number',pro_oem='$VObject->pro_oem',qty_minimum='$VObject->qty_minimum',listprice='$VObject->listprice',discount='$VObject->discount',netprice='$VObject->netprice',price='$VObject->price',price1='$VObject->price1',price2='$VObject->price2',price3='$VObject->price3',price4='$VObject->price4',price5='$VObject->price5',price6='$VObject->price6',currency_serialnumber='$VObject->currency_serialnumber',pro_group='$VObject->pro_group',pro_category='$VObject->pro_category',pro_manufacturer='$VObject->pro_manufacturer',pro_manufacture_date='$VObject->pro_manufacture_date',pro_image='$VObject->pro_image',pro_sku='$VObject->pro_sku',cre_userid='$VObject->cre_userid',cre_datetime='$VObject->cre_datetime',pro_description='$VObject->pro_description' where serialnumber='$VObject->serialnumber'";
  $s=  mysql_query($query) or die(mysql_error());
   if ($s=1)
      {
        mysql_query("COMMIT");
      }
      else
      {
        mysql_query("ROLLBACK");
      }
       return 'true';
  }
  
}
class VOProductMaster
{
     var $serialnumber;
     var $pro_code;
     var $pro_name;
     var $part_number;
     var $stamp_number;
     var $pro_oem;
	 var $qty_minimum;
     var $listprice;
	 var $discount;
	 var $netprice;
     var $price;
     var $price1;
     var $price2;
     var $price3;
     var $price4;
     var $price5;
     var $price6;
	 var $currency_serialnumber;
     var $pro_group;
     var $pro_category;
     var $pro_manufacturer;
     var $pro_manufacture_date;
     var $pro_image;
     var $pro_sku;
     var $cre_userid;
     var $cre_datetime;
     var $activestatus;
     var $pro_description;
}
?>